package utils.graph_helper;

import f_graph_basics.a_graph_representation.DenseGraph;
import f_graph_basics.a_graph_representation.Graph;
import f_graph_basics.a_graph_representation.SparseGraph;

import java.util.Random;

public class GraphHelper {
    public static Graph testSparseGraph1() {
        int v = 20;
        int e = 100;
        Random rand = new Random();
        SparseGraph sg = new SparseGraph(20, false);
        // 建立e条边
        for (int i = 0; i < e; i++) {
            sg.addEdge(rand.nextInt(v),rand.nextInt(v));
        }
        // 打印所有元素的邻边
        for (int i = 0; i < v; i++) {
            System.out.println(i +" --> "+ sg.getEdgesByVertex(i).toString());
        }
        System.out.println("=====================");
        return sg;
    }

    public static Graph testDenseGraph2() {
        int v = 20;
        int e = 100;
        Random rand = new Random();
        DenseGraph dg = new DenseGraph(20, false);
        // 建立e条边
        for (int i = 0; i < e; i++) {
            dg.addEdge(rand.nextInt(v),rand.nextInt(v));
        }
        // 打印所有元素的邻边
        for (int i = 0; i < v; i++) {
            System.out.println(i +" --> "+ dg.getEdgesByVertex(i).toString());
        }
        System.out.println("=====================");
        return dg;
    }
}
